using AutoMapper;
using XUCore.Ddd.Domain;
using XUCore.NetCore.DynamicWebApi;
using XUCore.NetCore.FreeSql.Curd;
using XUCore.NetCore.FreeSql.Entity;

namespace XUCore.NetCore.FreeSql
{
    /// <summary>
    /// 基于Curd操作的基类<para></para>
    /// 自动生成 Create、Update、Delete、BatchDelete、SoftDelete、BatchSoftDelete、Get、GetList、GetPage 操作<para></para>
    /// 其中自动生成API：Create、Update、Delete、Get、GetList、GetPage<para></para>
    /// 由于业务不同查询的条件不同，GetList、GetPage需要重写
    /// </summary>
    /// <typeparam name="TKey">主键类型</typeparam>
    /// <typeparam name="TEntity">数据库实体</typeparam>
    /// <typeparam name="TDto">返回实体</typeparam>
    /// <typeparam name="TCreateCommand">创建命令</typeparam>
    /// <typeparam name="TUpdateCommand">修改命令</typeparam>
    /// <typeparam name="TQueryCommand">查询列表命令</typeparam>
    /// <typeparam name="TQueryPageCommand">查询分页命令</typeparam>
    [DynamicWebApi]
    public abstract class CurdAppService<TKey, TEntity, TDto, TCreateCommand, TUpdateCommand, TQueryCommand, TQueryPageCommand> :
        FreeSqlCurdService<TKey, TEntity, TDto, TCreateCommand, TUpdateCommand, TQueryCommand, TQueryPageCommand>,
        ICurdAppService<TKey, TEntity, TDto, TCreateCommand, TUpdateCommand, TQueryCommand, TQueryPageCommand>,
        IDynamicWebApi,
        IScoped
            where TEntity : EntityFull<TKey>, new()
            where TDto : class, new()
            where TCreateCommand : CreateCommand
            where TUpdateCommand : UpdateCommand<TKey>
            where TQueryCommand : ListCommand
            where TQueryPageCommand : PageCommand
    {
        public CurdAppService(FreeSqlUnitOfWorkManager db, IMapper mapper, IUser user) :
            base(db, mapper, user)
        {

        }
    }

    /// <summary>
    /// 基于Curd操作的基类<para></para>
    /// 自动生成 Create、Update、Delete、BatchDelete、SoftDelete、BatchSoftDelete、Get、GetList、GetPage 操作<para></para>
    /// 其中自动生成API：Create、Update、Delete、Get、GetList、GetPage<para></para>
    /// 由于业务不同查询的条件不同，GetList、GetPage需要重写
    /// </summary>
    /// <typeparam name="TKey">主键类型</typeparam>
    /// <typeparam name="TEntity">数据库实体</typeparam>
    /// <typeparam name="TDto">返回实体</typeparam>
    /// <typeparam name="TCreateCommand">创建命令</typeparam>
    /// <typeparam name="TUpdateCommand">修改命令</typeparam>
    /// <typeparam name="TQueryCommand">查询列表命令</typeparam>
    /// <typeparam name="TQueryPageCommand">查询分页命令</typeparam>
    [DynamicWebApi]
    public interface ICurdAppService<TKey, TEntity, TDto, TCreateCommand, TUpdateCommand, TQueryCommand, TQueryPageCommand> :
        ICurdService<TKey, TEntity, TDto, TCreateCommand, TUpdateCommand, TQueryCommand, TQueryPageCommand>,
        IDynamicWebApi,
        IScoped
            where TEntity : EntityFull<TKey>, new()
            where TDto : class, new()
            where TCreateCommand : CreateCommand
            where TUpdateCommand : UpdateCommand<TKey>
            where TQueryCommand : ListCommand
            where TQueryPageCommand : PageCommand
    {
    }
}